<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>班组记录</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
	<!-- 班组记录的ID -->
	<input class="layui-hide" id="teamRecordId">
	<!-- 班组记录中的排产单的ID -->
	<input class="layui-hide" id="shedudetailIds">
	
	<div class="demoTable" style="padding:10px 0 0 15px">
    	<div class="layui-inline">
        	<input class="layui-input" name="keyWord" id="keyWord" placeholder="请输入班组名称" autocomplete="off">
    	</div> &nbsp; &nbsp; &nbsp; &nbsp;
    	<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
	</div>
	
<script type="text/html" id="toolbarDemo">
	
</script>
	
	
	<!-- 页面班组记录表 -->
	<table class="layui-hide" id="test" lay-filter="test"></table><br>
	<!-- 页面班组记录中具体员工数据表 -->
	<table class="layui-hide" id="testDetial" lay-filter="testDetial"></table><br>
	<!-- 页面班组记录中排产单数据表 -->
	<table class="layui-hide" id="testShedudetail" lay-filter="testShedudetail"></table>
	
 <!-- 班组记录的删除 -->
<script type="text/html" id="barDemo">
</script>
<!-- 	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->

 <!-- 员工记录的删除 -->
<script type="text/html" id="rowToolbar">
</script>
<!-- 	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del2">删除</a> -->

 <!-- 排产单记录的删除 -->
<script type="text/html" id="rowToolbar2">
</script>
<!-- 	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del3">删除</a> -->

	<!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
	<!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
              
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>

<script>
layui.use(['table','layer','upload','form'], function(){
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	
	var $ = layui.jquery, active = {
			reload:function () {
				var tname = $("#keyWord").val();
				table.reload('contenttable',{
					method:'get',
					where:{tname: tname},
					page:{
						curr:1  //重新从第一页开始
					}
				}); 
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/teamRecordMana/listPageTeamRecord.do'
	    //,toolbar: '#toolbarDemo'
	    ,title: '班组记录'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,cols: [[
	    	{field:'', title:'序号', sort: true, type:'numbers', width: 60}
	      	,{field:'tname', title:'班组名称'}
	      	,{field:'ttime', title:'记录日期'}
	      	,{field:'remark01', title:'班次'}
	      	,{field:'remark02', title:'开始时间'}
	      	,{field:'remark03', title:'结束时间'}
	      	,{field:'remarks', title:'备注'}
	      	//,{fixed:'right', title:'操作', toolbar: '#barDemo'}
	    ]]
	    ,page: true
	});
	
	//监听行单击事件(子表，当天哪些员工登录了)
	 table.on('row(test)', function(obj){
		$("#teamRecordId").val(obj.data.tid);
		$("#shedudetailIds").val(obj.data.productionId);
	  	table.render({
		    elem: '#testDetial'
		    ,url:'${pageContext.request.contextPath }/employeeRecordMana/listPageEmployeeRecord.do'
		    ,where:{tid: obj.data.tid}
		    ,title: '班组记录的员工详情数据表'
		    ,id :'contentDetialTable'
		    ,limits:[10,20,30]
		    ,cols: [
		    	[
		    	 {field:'', title:'当日员工统计',colspan: 9, align:'center'},	
		    	],
		    	[
		    	 {field:'', title:'序号', sort: true, type:'numbers', width: 60}
		    	 ,{field:'account', title:'工号'}
		    	 ,{field:'userName', title:'姓名'}
			     ,{field:'positionName', title:'工位'}
			     ,{field:'loginTime', title:'登录时间'}
			     ,{field:'logoutTime', title:'登出时间'}
			     ,{field:'remark01', title:'备注'}
			     //,{fixed:'right', title:'操作', toolbar: '#rowToolbar'} 
		    	]
		    ]
		    ,page: true
		});
	  	table.render({
		    elem: '#testShedudetail'
		    ,url:'${pageContext.request.contextPath }/teamRecordMana/selecDetailtList.do'
		    ,where:{productionId: obj.data.productionId}
		    ,title: '班组长选择的排产单详情数据表'
		    ,id :'contentDetialTable2'
		    ,limits:[10,20,30]
		    ,cols: [[
			      {field:'remark1', title:'日期',rowspan: 2,align:'center',width:150},
			      {field:'', title:'当日工作量统计值',colspan: 10, align:'center'},
			      {field:'', title:'0960T',colspan: 10, align:'center'},
			      {field:'', title:'0980T',colspan: 10, align:'center'},
			      {field:'', title:'1080C',colspan: 10, align:'center'},
			      {field:'', title:'1060B',colspan: 10, align:'center'},
			      //,{fixed:'right', title:'操作', toolbar: '#rowToolbar2'}
			    ],
			    [ 
			      {field:'a1', title:'膜丝烘干',width:100},
			      {field:'a2', title:'膜丝缓存',width:100},
			      {field:'a3', title:'膜芯制作',width:100},
			      {field:'a4', title:'组件组装',width:100},
			      {field:'a5', title:'膜丝切割',width:100},
			      {field:'a6', title:'浇铸端盖安装',width:120},
			      {field:'a7', title:'组件吊装离心',width:120},
			      {field:'a8', title:'浇铸端盖拆卸',width:120},
			      {field:'a9', title:'组件欲固化缓存',width:130},
			      {field:'a10', title:'组件切割',width:100},
			      
			      {field:'b1', title:'膜丝烘干',width:100},
			      {field:'b2', title:'膜丝缓存',width:100},
			      {field:'b3', title:'膜芯制作',width:100},
			      {field:'b4', title:'组件组装',width:100},
			      {field:'b5', title:'膜丝切割',width:100},
			      {field:'b6', title:'浇铸端盖安装',width:120},
			      {field:'b7', title:'组件吊装离心',width:120},
			      {field:'b8', title:'浇铸端盖拆卸',width:120},
			      {field:'b9', title:'组件欲固化缓存',width:130},
			      {field:'b10', title:'组件切割',width:100},
			      
			      {field:'c1', title:'膜丝烘干',width:100},
			      {field:'c2', title:'膜丝缓存',width:100},
			      {field:'c3', title:'膜芯制作',width:100},
			      {field:'c4', title:'组件组装',width:100},
			      {field:'c5', title:'膜丝切割',width:100},
			      {field:'c6', title:'浇铸端盖安装',width:120},
			      {field:'c7', title:'组件吊装离心',width:120},
			      {field:'c8', title:'浇铸端盖拆卸',width:120},
			      {field:'c9', title:'组件欲固化缓存',width:130},
			      {field:'c10', title:'组件切割',width:100},
			      
			      {field:'d1', title:'膜丝烘干',width:100},
			      {field:'d2', title:'膜丝缓存',width:100},
			      {field:'d3', title:'膜芯制作',width:100},
			      {field:'d4', title:'组件组装',width:100},
			      {field:'d5', title:'膜丝切割',width:100},
			      {field:'d6', title:'浇铸端盖安装',width:120},
			      {field:'d7', title:'组件吊装离心',width:120},
			      {field:'d8', title:'浇铸端盖拆卸',width:120},
			      {field:'d9', title:'组件欲固化缓存',width:130},
			      {field:'d10', title:'组件切割',width:100},
			      
			      {field:'e1', title:'膜丝烘干',width:100},
			      {field:'e2', title:'膜丝缓存',width:100},
			      {field:'e3', title:'膜芯制作',width:100},
			      {field:'e4', title:'组件组装',width:100},
			      {field:'e5', title:'膜丝切割',width:100},
			      {field:'e6', title:'浇铸端盖安装',width:120},
			      {field:'e7', title:'组件吊装离心',width:120},
			      {field:'e8', title:'浇铸端盖拆卸',width:120},
			      {field:'e9', title:'组件欲固化缓存',width:130},
			      {field:'e10', title:'组件切割',width:100},
			      
			    ]]
		    ,page: true
		});
	});
	
  
	//头工具栏事件(搜索，批量删除)
	table.on('toolbar(test)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'delete':
	        	var data = checkStatus.data;
	        	var str = "";
	        	if(data.length==0){
	        		toastr.warning("请至少选择一条记录！");
	        	}else{
	        		for(var i=0;i<data.length;i++){
		        		str += data[i].tid;
		        		if(i != data.length-1){
		        			str += ",";
		        		}
		        	}
		        	$.ajax({
				    	type:'post',
				    	url:'${pageContext.request.contextPath }/teamRecordMana/deleteTeamRecordOfVerify.do',
				    	data:{"str":str},
				    	dataType : "json",
				    	success:function(data){
				    		if(data>-1){
				    			toastr.warning("该条数据正在使用中，请勿删除！");
				    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
									//关闭模态框
									// 父页面刷新
									/* window.location.reload();   */
								},2000);
				    		}else{
				    			layer.confirm('确定删除吗？', function(index){
					        		$.ajax({
								    	type:'post',
								    	url:'${pageContext.request.contextPath }/teamRecordMana/deleteTeamRecord.do',
								    	data:{"str" : str},
								    	success:function(data){
								    		if(data>0){
								    			toastr.success("删除成功！");
								    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
													//关闭模态框
													// 父页面刷新
													window.location.reload();  
												},2000); 
								    		}else{
								    			toastr.error("删除失败！");
								    		}
								    	}
								    }); 
					        	});
				    		}
			    		}
			   	 	});
	        	}
	      	break; 
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
	
	/**
     * 监听班组记录表的行工具事件(删除班组记录)
     */
 	table.on('tool(test)', function(obj){
 		 if(obj.event === 'del'){
 		 	var tid = obj.data.tid;
 		 	$.ajax({
		    	type:'post',
		    	url:'${pageContext.request.contextPath }/teamRecordMana/deleteTeamRecordOfVerify.do',
		    	data:{"str":tid},
		    	dataType : "json",
		    	success:function(data){
		    		if(data>-1){
		    			toastr.warning("该条数据正在使用中，请勿删除！");
		    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							/* window.location.reload();   */
						},2000);
		    		}else{
		    			layer.confirm('确定删除吗？', function(index){
		    	 		 	$.ajax({
		    	 				url : '${pageContext.request.contextPath }/teamRecordMana/deleteTeamRecord.do',
		    	 				data : {"str":tid},
		    	 				type : "post",
		    	 				dataType : "json",
		    	 				}).done(
		    	 					function(res) {
		    	 						if (res > 0) {
		    	 							toastr.success('删除成功！');
		    	 							setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
		    	 								//关闭模态框
		    	 								// 父页面刷新
		    	 								window.location.reload(); 
		    	 							},2000);
		    	 						}else{
		    	 							toastr.error('删除失败！');
		    	 						}
		    	 					}
		    	 				).fail(
		    	 					function(res) {
		    	 						toastr.error('删除失败！');
		    	 					}
		    	 				)
		    	 				return false;
		    	 		 });
					}
	    		}
	   	 	});
 		}
 	});
	
	/**
     * 监听员工表的行工具事件(删除员工记录)
     */
 	table.on('tool(testDetial)', function(obj){
 		 if(obj.event === 'del2'){
 		 	var id = obj.data.id;
 		 	layer.confirm('确定删除吗？', function(index){
 		 	$.ajax({
 				url : '${pageContext.request.contextPath }/employeeRecordMana/deleteEmployeeRecord.do',
 				data : {"id":id},
 				type : "post",
 				dataType : "json",
 				}).done(
 					function(res) {
 						if (res > 0) {
 							toastr.success('删除成功！');
 							setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
 								//关闭模态框
 								// 父页面刷新
 								window.location.reload(); 
 							},2000);
 						}
 					}
 				).fail(
 					function(res) {
 						toastr.error('删除失败！');
 					}
 				)
 				return false;
 		 	});
 		}
 	});
	
 	/**
     * 监听排产单表的行工具事件(删除排产单)
     */
 	table.on('tool(testShedudetail)', function(obj){
 		 if(obj.event === 'del3'){
 		 	var id = obj.data.id;
 		 	var pid = $("#shedudetailIds").val();
 		 	if(pid.indexOf(",") != -1 ){
 		 		layer.confirm('确定删除吗？', function(index){
 		 			$.ajax({
 		 				url : '${pageContext.request.contextPath }/teamRecordMana/deleteTeamRecordOfPid.do',
 		 				data : {"shedudetailId":id, "teamRecordId":$("#teamRecordId").val()},
 		 				type : "post",
 		 				dataType : "json",
 		 				}).done(
 		 					function(res) {
 		 						if (res > 0) {
 		 							toastr.success('删除成功！');
 		 							setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
 		 								//关闭模态框
 		 								// 父页面刷新
 		 								window.location.reload(); 
 		 							},2000);
 		 						}else {
 		 							toastr.error('删除失败！');
 		 						}
 		 					}
 		 				).fail(
 		 					function(res) {
 		 						toastr.error('删除失败！');
 		 					}
 		 				)
 		 				return false;
 		 		});
 		 	}else{
 		 		toastr.warning('至少保留一条数据！');
 		 	}
 		}
 	});
	
});

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上

</script>
</body>
</html>